package com.guo.todo.common.response;

import java.lang.reflect.Member;

/**
 * @Auther: hotlove_linx
 * @Date: 2022/4/16 17:24
 * @Description:
 */
public class Result {

    private String code;

    private String message;

    private Object data;

    public Result(String code, String message) {
        this.code = code;
        this.message = message;
    }

    public Result(String code, Object data) {
        this.code = code;
        this.data = data;
    }

    public Result(String code, Object data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public Result(ResultEnum resultEnum) {
        this(resultEnum.getCode(), resultEnum.getMessage());
    }

    public Result(ResultEnum resultEnum, Object data) {
        this(resultEnum);
        this.data = data;
    }

    public static Result success(Object data) {
        return new Result(ResultEnum.SUCCESS.getCode(), data);
    }

    public static Result fail(String message) {
        return new Result(ResultEnum.FAIL.getCode(), message);
    }

    public static Result fail(String code, String message) {
        return new Result(code, message);
    }

    public static Result fail(ResultEnum resultEnum) {
        return new Result(resultEnum);
    }

    public static Result fail(Object data, String message) {
        return new Result(ResultEnum.FAIL.getCode(), data, message);
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }
}
